﻿@model UserSimpleDto
<div class="py-3 text-center">
    <h3>域账号管理</h3>
    <!--<div id="msg" class="form-group pt-3 text-danger">请先修改密码</div>-->
</div>

<div class="alert alert-success" role="alert">
    <h4 class="alert-heading">域账号需知</h4>
    <hr/>
    <p>1、LDAP服务每隔一分钟同步一次域账号信息，域账号开通后，请等待一分钟！</p>
    <p>2、域账号开通后，请先修改初始密码，以启用账号！</p>
    <p>3、VPN账号启用后即时生效，VPN的账号密码与域账号一致！</p>
</div>
@if (Model == null || !Model.EnableAccount)
{
    <div class="alert alert-danger" role="alert">
        <p>您的账号尚未开通，请联系管理员开通！</p>
    </div>
}
else
{
<ul class="nav nav-tabs">
    <li class="nav-item">
        <a class="nav-link active" data-toggle="tab" href="#personnel">个人账号管理</a>
    </li>
    @if (Model.IsAdmin)
    {
        <li class="nav-item">
            <a class="nav-link" id="btnDeptUsers" data-toggle="tab" href="#deptusers">员工账号管理</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" id="btnOutSideUsers" data-toggle="tab" href="#outSideUsers">外部人员账号管理</a>
        </li>
    }
</ul>

    <!-- 选项卡对应内容 -->
<div class="tab-content">
    <div class="tab-pane  active container" id="personnel">
        <form id="formChangePassword">
            <div class="row pt-3">
                <div class="col-md-8 mb-2 offset-md-2">
                    <div class="row">
                        @Html.HiddenFor(t => t.UserId)
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label>姓名：</label>@Model.Name
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="form-group">
                                <label>用户名：</label>@Model.UserName
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-8 mb-2 offset-md-2">
                    <div class="form-group">
                        <label>当前密码</label>
                        <a href="/ForgotPassword">忘记密码</a>
                        @Html.ValidationMessageFor(t => t.OldPassword)
                        @Html.PasswordFor(t => t.OldPassword, new { @class = "form-control", placeholder = "请输入当前密码" })
                        @*<input class="form-control" id="OldPassword" name="OldPassword" type="password" placeholder="请输入当前密码" maxlength="16" />*@
                    </div>
                </div>
                <div class="col-md-8 mb-2 offset-md-2">
                    <div class="form-group">
                        <label>新密码</label> @Html.ValidationMessageFor(t => t.NewPassword)
                        @Html.PasswordFor(t => t.NewPassword, new { @class = "form-control", placeholder = "请输入新密码" })
                        @*<input class="form-control" id="NewPassword" name="NewPassword" type="password" placeholder="请输入新密码" maxlength="16" />*@
                    </div>
                </div>
                <div class="col-md-8 mb-2 offset-md-2">
                    <div class="form-group">
                        <label>确认密码</label> @Html.ValidationMessageFor(t => t.ConfirmPassword)
                        @Html.PasswordFor(t => t.ConfirmPassword, new { @class = "form-control", placeholder = "请输入确认密码" })
                        @*<input class="form-control" id="ConfirmPassword" name="ConfirmPassword" type="password" placeholder="请输入确认密码" maxlength="16" />*@
                    </div>
                </div>
                <div class="col-md-8 mb-2 offset-md-2">
                    <div class="form-group">
                        <button id="btnChangePassword" type="button" class="btn btn-block btn-primary">修 改</button>
                    </div>
                    @if (Model.IsAdmin && !Model.EnableVpnAccount)
                    {
                        <div class="form-group">
                            <button id="btnEnableVpnAccount" type="button" class="btn btn-block btn-success">启 用 VPN 账 号</button>
                        </div>
                    }
                </div>
            </div>
        </form>
    </div>

    @if (Model.IsAdmin)
    {
        <div class="tab-pane  container" id="deptusers">
            <div class="row pt-3 text-center">
                <table id="tabDeptUsers" class="table table-bordered " aria-describedby="下属员工列表">
                    <thead>
                        <tr>
                            <th>姓名</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="tab-pane  container" id="outSideUsers">
            <div class="row pt-3 text-center">
                <a data-toggle="modal" data-target="#AddOutSideUserModal" href="javascript:void(0)">新增外部人员</a>
                <table id="tabOutSideUsers" class="table table-bordered " aria-describedby="外部人员列表">
                    <thead>
                        <tr>
                            <th>姓名</th>
                            <th>邮箱</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    }
</div>
}
   
@await Html.PartialAsync("UserDetailModal.cshtml")           
@await Html.PartialAsync("AddOutSideUserModal.cshtml")


@await Html.PartialAsync("~/Views/Shared/resultModal.cshtml")

@section Scripts{
    <script src="/js/Manage.js"></script>

}